<?php if (isset($_SERVER['HTTP_USER_AGENT']) && !strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6'))
    echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>" xml:lang="<?php echo $lang; ?>">
    <head>
        <title><?php echo $title; ?></title>
        <base href="<?php echo $base; ?>" />
        <?php if ($description) { ?>
            <meta name="description" content="<?php echo $description; ?>" />
        <?php } ?>
        <?php if ($keywords) { ?>
            <meta name="keywords" content="<?php echo $keywords; ?>" />
        <?php } ?>
        <?php if ($icon) { ?>
            <link href="<?php echo $icon; ?>" rel="icon" />
        <?php } ?>
        <?php foreach ($links as $link) { ?>
            <link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" />
        <?php } ?>
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/stylesheet.css" />
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/home.css" />
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/reset.css" />
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/header.css" />
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/menu.css" />	
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/yahoo.css" />
       

        <?php foreach ($styles as $style) { ?>
            <link rel="<?php echo $style['rel']; ?>" type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" />
        <?php } ?>
        <script> 
            function FloatTopDiv() 
            { 
                startLX = ((document.body.clientWidth -MainContentW)/2)-LeftBannerW-LeftAdjust , startLY = TopAdjust+80; 
                startRX = ((document.body.clientWidth -MainContentW)/2)+MainContentW+RightAdjust , startRY = TopAdjust+80; 
                var d = document; 
                function ml(id) 
                { 
                    var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id]; 
                    el.sP=function(x,y){this.style.left=x + 'px';this.style.top=y + 'px';}; 
                    el.x = startRX; 
                    el.y = startRY; 
                    return el; 
                } 
                function m2(id) 
                { 
                    var e2=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id]; 
                    e2.sP=function(x,y){this.style.left=x + 'px';this.style.top=y + 'px';}; 
                    e2.x = startLX; 
                    e2.y = startLY; 
                    return e2; 
                } 
                window.stayTopLeft=function() 
                { 
                    if (document.documentElement && document.documentElement.scrollTop) 
                        var pY =  document.documentElement.scrollTop; 
                    else if (document.body) 
                        var pY =  document.body.scrollTop; 
                    if (document.body.scrollTop > 30){startLY = 3;startRY = 3;} else {startLY = TopAdjust;startRY = TopAdjust;}; 
                    ftlObj.y += (pY+startRY-ftlObj.y)/16; 
                    ftlObj.sP(ftlObj.x, ftlObj.y); 
                    ftlObj2.y += (pY+startLY-ftlObj2.y)/16; 
                    ftlObj2.sP(ftlObj2.x, ftlObj2.y); 
                    setTimeout("stayTopLeft()", 1); 
                } 
                ftlObj = ml("divAdRight"); 
                //stayTopLeft(); 
                ftlObj2 = m2("divAdLeft"); 
                stayTopLeft(); 
            } 
            function ShowAdDiv() 
            { 
                var objAdDivRight = document.getElementById("divAdRight"); 
                var objAdDivLeft = document.getElementById("divAdLeft");        
                if (document.body.clientWidth < 1000) 
                { 
                    objAdDivRight.style.display = "none"; 
                    objAdDivLeft.style.display = "none"; 
                } 
                else 
                { 
                    objAdDivRight.style.display = "block"; 
                    objAdDivLeft.style.display = "block"; 
                    FloatTopDiv(); 
                } 
            }  
        </script> 

        <script> 
            document.write("<script type='text/javascript' language='javascript'>MainContentW = 980;LeftBannerW = 127;RightBannerW = 127;LeftAdjust = 40;RightAdjust = 20;TopAdjust = 100;ShowAdDiv();window.onresize=ShowAdDiv;;<\/script>"); 
        </script>
        
        <script type="text/javascript" src="catalog/view/javascript/jquery/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-1.8.16.custom.min.js"></script>
        <link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/ui/themes/ui-lightness/jquery-ui-1.8.16.custom.css" />
        <script type="text/javascript" src="catalog/view/javascript/jquery/ui/external/jquery.cookie.js"></script>
        <script type="text/javascript" src="catalog/view/javascript/jquery/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
        <script type="text/javascript" src="catalog/view/javascript/jquery/cycle/jquery.cycle.all.latest.js" ></script>
        <link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<!--        [if IE]>
        <script type="text/javascript" src="catalog/view/javascript/jquery/fancybox/jquery.fancybox-1.3.4-iefix.js"></script>
        <![endif] -->
        <script type="text/javascript" src="catalog/view/javascript/jquery/tabs.js"></script>
        <script type="text/javascript" src="catalog/view/javascript/common.js"></script>
        <script type="text/javascript" src="catalog/view/theme/default/js/thanhntt89.js"></script>
        <script src="catalog/view/theme/default/plugin/jcarousellite/jcarousellite_1.0.1.min.js" type="text/javascript"></script> 
        <script src="js/jquery-latest.pack.js" type="text/javascript"></script>
        <script src="catalog/view/theme/default/plugin/superfish/js/superfish.js" type="text/javascript"></script>   
        <script src="catalog/view/theme/default/plugin/cycle/jquery.cycle.all.latest.js" type="text/javascript"></script>
        <script type="text/javascript">

        $(function () {
            $('.menu-top ul.sf-menu').superfish();
            $(".anyClass").jCarouselLite({
                btnNext: ".next",
                btnPrev: ".prev",
                visible: 5,
                auto: 800,
                speed: 1000
            });
            $('.banner-left div').cycle({
                timeout: 3000,
                pager: '#nav',
                pagerAnchorBuilder: function (idx, slide) {
                    return '<li><a href="#"><div class="banner-btn"></div></a></li>';
                }
            });

        });
        $.fn.cycle.updateActivePagerLink = function (pager, currSlideIndex) {
            $(pager).find('li').removeClass('activeLI')
        .filter('li:eq(' + currSlideIndex + ')').addClass('activeLI');
        };

        $.fn.cycle.updateActivePagerLink = function (pager, currSlide, clsName) {
            $(pager).each(function () {
                console.log(clsName + '; ' + currSlide);
                $(this).children().removeClass('activeLI').filter(':eq(' + currSlide + ')').addClass('activeLI');
            });
        };
    </script>   
        <?php foreach ($scripts as $script) { ?>
            <script type="text/javascript" src="<?php echo $script; ?>"></script>
        <?php } ?>
<!--        [if IE 7]>
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/ie7.css" />
        <![endif]-->
<!--        [if lt IE 7]>
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/ie6.css" />
        <script type="text/javascript" src="catalog/view/javascript/DD_belatedPNG_0.0.8a-min.js"></script>
        <script type="text/javascript">
        DD_belatedPNG.fix('#logo img');
        </script>
        <![endif]-->
        <?php echo $google_analytics; ?>
    </head>
    <body>
        <div class="top"></div>
        <div id="container">     
            <div class="header">
                <div class="login">
                    <?php if (!$logged) { ?>
                        <span style="color:red;">Website đang chạy thử nghiệm </span><?php echo $text_welcome; ?>
                    <?php } else { ?>
                        <?php echo $text_logged; ?>
                    <?php } ?>                 

                    <a class="language-e" href="#"></a>
                    <a class="language-vn" href="#"></a>            
                </div>
                <div class="clear"></div>
                <div class="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
                <div class="logo-right">
                    <div id="cart">
                        <div class="heading">
                            <span><?php echo $text_cart; ?></span>
                            <span id="cart_total"><?php echo $text_items; ?></span>
                        </div>
                        <div class="content"></div>
                    </div>
                    <!--                        <div class="search">
                                                <input type="text" class="search-text"/>                    
                                                <input type="button" class="search-button"/>    
                                            </div>-->
                    <!--                        <div id="search">
                                                <div class="button-search"></div>
                    <?php if ($filter_name) { ?>
                                                            <input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
                    <?php } else { ?>
                                                            <input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
                    <?php } ?>
                                            </div>-->

                    <div id="search">
                        <div class="button-search"></div>
                        <?php if ($filter_name) { ?>
                            <input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
                        <?php } else { ?>
                            <input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
                        <?php } ?>
                    </div>
                </div>
                <div class="clear"></div>     

                <div class="menu">
                    <ul>
                        <li> <a href=" <?php echo $home; ?>"> <span> <?php echo $text_home; ?></span></a></li>
                        <li> <a href=" <?php echo $account; ?> "><span><?php echo $text_account; ?></span></a></li>
                        <li> <a href=" <?php echo $cart; ?> "> <span><?php echo $text_cart; ?></span></a></li>
                        <li> <a href="<?php echo $checkout; ?>"><span> <?php echo $text_checkout; ?></span></a></li>
                        <li class="mobie-online">Đặt hàng 094 534 8444</li>
                    </ul>
                </div>
                <div class="clear"></div>
                           
            </div>          

<?php if ($categories) { ?>
                    <div id="menu">
                        <ul>
                            <?php foreach ($categories as $category) { ?>
                                <li><a href="<?php echo $category['href']; ?>"><span><?php echo $category['name']; ?></span></a>
                                    <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
                                </li>
                            <?php } ?>
                        </ul>
                    </div>
                <?php } ?>
       <div id="notification"></div>

